// 员工相关API
import request from '@/utils/request'

// 获取员工简单列表
const getEmployeeSimpleAPI = () => request.get('/sys/user/simple')

// 获取员工列表 page(页码) size(每页条数)
const getEmployeeListAPI = (params) => request.get('/sys/user', { params })

// 删除员工接口
const delEmployeeListAPI = (id) => request.delete(`/sys/user/${id}`)

// 新增员工
const addEmployeeListAPI = (data) => request.post('/sys/user', data)

// 批量导入员工 参数data是一个数组类型
const importEmployeesAPI = (data) => request.post('/sys/user/batch', data)

// 保存员工基本信息
const saveEmployeesAPI = (data) => request.put(`/sys/user/${data.id}`, data)

// 获取员工个人信息
const getPersonalDetailAPI = (id) =>
  request.get(`/employees/${id}/personalInfo`)

// 更新员工个人信息
const updatePersonalAPI = (data) =>
  request.put(`/employees/${data.userId}/personalInfo`, data)

// 获取员工岗位信息
const getJobDetailAPI = (id) => request.get(`/employees/${id}/jobs`)

// 更新员工岗位信息
const updateJobAPI = (data) =>
  request.put(`/employees/${data.userId}/jobs`, data)

// 给员工分配角色
const assignRolesAPI = (data) => request.put('/sys/user/assignRoles', data)

export {
  getEmployeeSimpleAPI,
  getEmployeeListAPI,
  delEmployeeListAPI,
  addEmployeeListAPI,
  importEmployeesAPI,
  saveEmployeesAPI,
  getPersonalDetailAPI,
  updatePersonalAPI,
  getJobDetailAPI,
  updateJobAPI,
  assignRolesAPI
}
